Add Authentication & User history#34
Conversation
There was a problem hiding this comment.
I think this PR is very cool.
I pointed several weird python condition testing in the code.
For the front, I think we still need to organize it a bit better, but we can leave that for future work.
The authentication is a bit messy, and is sometimes using the API client, and other times creating a new Axios client which is a bit weird, inconsistent, and less effective than always using the same client.
| return return_value | ||
|
|
||
|
|
||
| def populate_db_from_remote_server(remotePath, ListOfVideos): |
| """ | ||
| cmd = ["ffmpeg", "-n", "-sub_charenc", "UTF-8", "-i", input_file, output_file] | ||
| if(os.path.isfile(output_file) == False): | ||
| if(os.path.isfile(output_file) is False): |
There was a problem hiding this comment.
When doing conditions on boolean values in Python, we usually would do:
if not os.path.isfile(output_file):Have a look here for instance.
| cmd = ["ffmpeg", "-n", "-sub_charenc", "UTF-8", "-i", input_file,"-map", "0:s:0", output_file] | ||
| if(os.path.isfile(output_file) == False): | ||
| cmd = ["ffmpeg", "-n", "-sub_charenc", "UTF-8", "-i", input_file, "-map", "0:s:0", output_file] | ||
| if(os.path.isfile(output_file) is False): |
| "-codec", "copy", "-movflags", "+faststart", output_file] | ||
|
|
||
| if(os.path.isfile(output_file) == False): | ||
| if(os.path.isfile(output_file) is False): |
| cmd = ["ffmpeg", "-ss", str(duration/2.0), "-i", input_file, "-an", "-vf", "scale=320:-1", | ||
| "-vframes", "1", output_file] | ||
| if(os.path.isfile(output_file) == False): | ||
| if(os.path.isfile(output_file) is False): |
| """ # init cache for subtitles database query and stuff. | ||
| """ | ||
| if(os.path.isfile('cachefile.dbm.db') == False): | ||
| if(os.path.isfile('cachefile.dbm.db') is False): |
| video_path, Language(langage)) | ||
| webvtt_en_fullpath = os.path.splitext(srt_fullpath)[0]+'.vtt' | ||
| if(os.path.isfile(webvtt_en_fullpath) == True): | ||
| if(os.path.isfile(webvtt_en_fullpath) is True): |
There was a problem hiding this comment.
if os.path.isfile(webvtt_en_fullpath):| if(os.path.isfile(webvtt_en_fullpath) is True): | ||
| #return subtitles path even if subtitles are already downloaded/converted | ||
| return webvtt_en_fullpath | ||
| if(os.path.isfile(srt_fullpath)): |
| router.register(r'videos', videos.VideoViewSet, basename='videos') | ||
| router.register(r'series', videos.SeriesViewSet, basename='series') | ||
| router.register(r'movies', videos.MoviesViewSet, basename='movies') | ||
| # router.register(r'history', accounts.HistoryViewSet, basename='history') |
| if (VERBOSE_OUTPUT == True): | ||
| customstdout=subprocess.PIPE | ||
| customstderr=subprocess.PIPE | ||
| if (VERBOSE_OUTPUT is True): |
| const { setAuthTokens } = useAuth(); | ||
|
|
||
| function postLogin() { | ||
| const http = axios.create({ |
There was a problem hiding this comment.
Why do we create a new axios client here?
| const { setAuthTokens } = useAuth(); | ||
|
|
||
| function postSignup() { | ||
| const http = axios.create({ |
| baseURL: process.env.REACT_APP_DJANGO_API, | ||
| responseType: 'json', | ||
| }); | ||
| http.post("/rest-auth/registration/", { |
There was a problem hiding this comment.
Here we use the API client, but it would be nice not to hardcode any API url in the front code, and organize it like we started in the API client file.
xavierfav
left a comment
There was a problem hiding this comment.
Nice, thanks for the changes @DerouineauNicolas.
It's still not perfect for the authentication feature in front (e.g., harcoded path and no client method for login/logout/singup), but I think it is enough for now!
Good job!
This PR aims to adress issue #4 and #5.
The follwing features are added:
adds token-auth authentification to DRF backend
add login/subcribe pages in the frontend
push informations from front to back when a authenticated user watches a video (videoid and current playing time in the media)
allow authenticated users to get their viewing history in the frontend.
Moreover, several improvements have been done on the frontend side (code refactoring and UI).
A cross check for existing files in the database is also added when updating database:
docker-compose -f docker-compose-prod.yml run --rm web python3 manage.py updatedb